home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_gimp / SHARE / ACLOCAL / GIMP.M4 < prev   
Text File  |  1999-09-17  |  6KB  |  167 lines

  1. # Configure paths for GIMP
  2. # Manish Singh    98-6-11
  3. # Shamelessly stolen from Owen Taylor
  4.  
  5. dnl AM_PATH_GIMP([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  6. dnl Test for GIMP, and define GIMP_CFLAGS and GIMP_LIBS
  7. dnl
  8. AC_DEFUN(AM_PATH_GIMP,
  9. [dnl 
  10. dnl Get the cflags and libraries from the gimptool script
  11. dnl
  12. AC_ARG_WITH(gimp-prefix,[  --with-gimp-prefix=PFX   Prefix where GIMP is installed (optional)],
  13.             gimptool_prefix="$withval", gimptool_prefix="")
  14. AC_ARG_WITH(gimp-exec-prefix,[  --with-gimp-exec-prefix=PFX Exec prefix where GIMP is installed (optional)],
  15.             gimptool_exec_prefix="$withval", gimptool_exec_prefix="")
  16. AC_ARG_ENABLE(gimptest, [  --disable-gimptest       Do not try to compile and run a test GIMP program],
  17.             , enable_gimptest=yes)
  18.  
  19.   if test x$gimptool_exec_prefix != x ; then
  20.      gimptool_args="$gimptool_args --exec-prefix=$gimptool_exec_prefix"
  21.      if test x${GIMPTOOL+set} != xset ; then
  22.         GIMPTOOL=$gimptool_exec_prefix/bin/gimptool
  23.      fi
  24.   fi
  25.   if test x$gimptool_prefix != x ; then
  26.      gimptool_args="$gimptool_args --prefix=$gimptool_prefix"
  27.      if test x${GIMPTOOL+set} != xset ; then
  28.         GIMPTOOL=$gimptool_prefix/bin/gimptool
  29.      fi
  30.   fi
  31.  
  32.   AC_PATH_PROG(GIMPTOOL, gimptool, no)
  33.   min_gimp_version=ifelse([$1], ,1.0.0,$1)
  34.   AC_MSG_CHECKING(for GIMP - version >= $min_gimp_version)
  35.   no_gimp=""
  36.   if test "$GIMPTOOL" = "no" ; then
  37.     no_gimp=yes
  38.   else
  39.     GIMP_CFLAGS=`$GIMPTOOL $gimptool_args --cflags`
  40.     GIMP_LIBS=`$GIMPTOOL $gimptool_args --libs`
  41.  
  42.     GIMP_CFLAGS_NOUI=`$GIMPTOOL $gimptool_args --cflags-noui`
  43.     noui_test=`echo $GIMP_CFLAGS_NOUI | sed 's/^\(Usage\).*/\1/'`
  44.     if test "$noui_test" = "Usage" ; then
  45.        GIMP_CFLAGS_NOUI=$GIMP_CFLAGS
  46.        GIMP_LIBS_NOUI=$GIMP_LIBS
  47.     else
  48.        GIMP_LIBS_NOUI=`$GIMPTOOL $gimptool_args --libs-noui`
  49.     fi
  50.  
  51.     gimptool_major_version=`$GIMPTOOL $gimptool_args --version | \
  52.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  53.     gimptool_minor_version=`$GIMPTOOL $gimptool_args --version | \
  54.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  55.     gimptool_micro_version=`$GIMPTOOL $gimptool_args --version | \
  56.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  57.     if test "x$enable_gimptest" = "xyes" ; then
  58.       ac_save_CFLAGS="$CFLAGS"
  59.       ac_save_LIBS="$LIBS"
  60.       CFLAGS="$CFLAGS $GIMP_CFLAGS"
  61.       LIBS="$LIBS $GIMP_LIBS"
  62. dnl
  63. dnl Now check if the installed GIMP is sufficiently new. (Also sanity
  64. dnl checks the results of gimptool to some extent
  65. dnl
  66.       rm -f conf.gimptest
  67.       AC_TRY_RUN([
  68. #include <stdio.h>
  69. #include <stdlib.h>
  70. #include <libgimp/gimp.h>
  71.  
  72. GPlugInInfo PLUG_IN_INFO =
  73. {
  74.   NULL,  /* init_proc */
  75.   NULL,  /* quit_proc */
  76.   NULL,  /* query_proc */
  77.   NULL   /* run_proc */
  78. };
  79.  
  80. int main ()
  81. {
  82.   int major, minor, micro;
  83.   char *tmp_version;
  84.  
  85.   system ("touch conf.gimptest");
  86.  
  87.   /* HP/UX 9 (%@#!) writes to sscanf strings */
  88.   tmp_version = g_strdup("$min_gimp_version");
  89.   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
  90.      printf("%s, bad version string\n", "$min_gimp_version");
  91.      exit(1);
  92.    }
  93.  
  94.     if (($gimptool_major_version > major) ||
  95.         (($gimptool_major_version == major) && ($gimptool_minor_version > minor)) ||
  96.         (($gimptool_major_version == major) && ($gimptool_minor_version == minor) && ($gimptool_micro_version >= micro)))
  97.     {
  98.       return 0;
  99.     }
  100.   else
  101.     {
  102.       printf("\n*** 'gimptool --version' returned %d.%d.%d, but the minimum version\n", $gimptool_major_version, $gimptool_minor_version, $gimptool_micro_version);
  103.       printf("*** of GIMP required is %d.%d.%d. If gimptool is correct, then it is\n", major, minor, micro);
  104.       printf("*** best to upgrade to the required version.\n");
  105.       printf("*** If gimptool was wrong, set the environment variable GIMPTOOL\n");
  106.       printf("*** to point to the correct copy of gimptool, and remove the file\n");
  107.       printf("*** config.cache before re-running configure\n");
  108.       return 1;
  109.     }
  110. }
  111.  
  112. ],, no_gimp=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  113.        CFLAGS="$ac_save_CFLAGS"
  114.        LIBS="$ac_save_LIBS"
  115.      fi
  116.   fi
  117.   if test "x$no_gimp" = x ; then
  118.      AC_MSG_RESULT(yes)
  119.      ifelse([$2], , :, [$2])     
  120.   else
  121.      AC_MSG_RESULT(no)
  122.      if test "$GIMPTOOL" = "no" ; then
  123.        echo "*** The gimptool script installed by GIMP could not be found"
  124.        echo "*** If GIMP was installed in PREFIX, make sure PREFIX/bin is in"
  125.        echo "*** your path, or set the GIMPTOOL environment variable to the"
  126.        echo "*** full path to gimptool."
  127.      else
  128.        if test -f conf.gimptest ; then
  129.         :
  130.        else
  131.           echo "*** Could not run GIMP test program, checking why..."
  132.           CFLAGS="$CFLAGS $GIMP_CFLAGS"
  133.           LIBS="$LIBS $GIMP_LIBS"
  134.           AC_TRY_LINK([
  135. #include <stdio.h>
  136. #include <libgimp/gimp.h>
  137. ],      [ return 0; ],
  138.         [ echo "*** The test program compiled, but did not run. This usually means"
  139.           echo "*** that the run-time linker is not finding GIMP or finding the wrong"
  140.           echo "*** version of GIMP. If it is not finding GIMP, you'll need to set your"
  141.           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  142.           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  143.           echo "*** is required on your system"
  144.       echo "***"
  145.           echo "*** If you have an old version installed, it is best to remove it, although"
  146.           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  147.         [ echo "*** The test program failed to compile or link. See the file config.log for the"
  148.           echo "*** exact error that occured. This usually means GIMP was incorrectly installed"
  149.           echo "*** or that you have moved GIMP since it was installed. In the latter case, you"
  150.           echo "*** may want to edit the gimptool script: $GIMPTOOL" ])
  151.           CFLAGS="$ac_save_CFLAGS"
  152.           LIBS="$ac_save_LIBS"
  153.        fi
  154.      fi
  155.      GIMP_CFLAGS=""
  156.      GIMP_LIBS=""
  157.      GIMP_CFLAGS_NOUI=""
  158.      GIMP_LIBS_NOUI=""
  159.      ifelse([$3], , :, [$3])
  160.   fi
  161.   AC_SUBST(GIMP_CFLAGS)
  162.   AC_SUBST(GIMP_LIBS)
  163.   AC_SUBST(GIMP_CFLAGS_NOUI)
  164.   AC_SUBST(GIMP_LIBS_NOUI)
  165.   rm -f conf.gimptest
  166. ])
  167.